<?php

use console\db\Migration;

/**
 * APP帮助相关信息表
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m150104_091358_t_help extends Migration {

    /**
     * {@inheritdoc}
     */
    public function up() {

        /**
         * APP帮助信息表
         * @table `help`.
         */
        $this->tableBuilder([
            'name' => 'help',
            'comment' => 'APP帮助信息表',
            'columns' => [
                'id' => $this->primaryKey(),
                'category_id' => $this->integer(11)->unsigned()->notNull()->defaultValue(0)->comment('帮助所属分类ID'),
                'title' => $this->string(64)->notNull()->comment('标题'),
                'thumb' => $this->char(255)->defaultValue('')->comment('内容封面'),
                'listorder' => $this->integer(11)->unsigned()->notNull()->defaultValue(0)->comment('显示排序'),
                'content' => $this->text()->notNull()->comment('帮助内容'),
                'recommend_at' => $this->unixtimestamp()->comment('推荐时间'),
                'views' => $this->integer(11)->unsigned()->notNull()->defaultValue(0)->comment('浏览次数'),
                'system' => $this->char(50)->unique()->comment('系统识别名'),
                'template' => $this->char(50)->defaultValue('')->comment('自定义模板'),
                'admin_id' => $this->integer(11)->unsigned()->notNull()->defaultValue(0)->comment('管理员ID'),
                'status' => $this->tinyint(1)->notNull()->defaultValue(0)->comment('状态'),
                'created_at' => $this->unixtimestamp()->comment('创建时间'),
                'updated_at' => $this->unixtimestamp()->comment('更新时间'),
            ],
        ]);
        /**
         * APP帮助信息栏目表
         * @table `help_category`.
         */
        $this->tableBuilder([
            'name' => 'help_category',
            'comment' => 'APP帮助信息栏目表',
            'columns' => [
                'id' => $this->primaryKey(),
                'name' => $this->string(50)->notNull()->comment('名称'),
                'description' => $this->string(255)->defaultValue('')->comment('描述'),
                'icon' => $this->char(255)->defaultValue('')->comment('图标'),
                'color' => $this->char(7)->defaultValue('#ff6600')->comment('图标颜色'),
                'content_id' => $this->integer(11)->unsigned()->notNull()->defaultValue(0)->comment('直接跳转ID'),
                'listorder' => $this->integer(11)->unsigned()->notNull()->defaultValue(0)->comment('显示排序'),
                'system' => $this->tinyint(1)->unsigned()->notNull()->defaultValue(0)->comment('是否系统栏目'),
                'status' => $this->tinyint(1)->notNull()->defaultValue(0)->comment('状态'),
                'created_at' => $this->unixtimestamp()->comment('创建时间'),
                'updated_at' => $this->unixtimestamp()->comment('更新时间'),
            ],
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function down() {
        $this->dropTable('{{%help_category}}');
        $this->dropTable('{{%help}}');
    }

}
